//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace OpenLS.Spreadsheet.UI
{
    class BorderStyleToDashConverter: IValueConverter
    {

        public static DashStyle StyleToDash(BorderStyle style)
        {
            switch (style)
            {
                case BorderStyle.None:
                    return DashStyles.Solid;
                case BorderStyle.DashDot:
                    return DashStylesEx.DashDotDoubled;
                case BorderStyle.DashDotDot:
                    return DashStylesEx.DashDotDotDoubled;
                case BorderStyle.Dashed:
                    return DashStylesEx.DashDoubled;
                case BorderStyle.Dotted:
                    return DashStylesEx.DotDoubled;
                case BorderStyle.Hair:
                    return DashStylesEx.Hair;
                case BorderStyle.MediumDashDot:
                    return DashStylesEx.MediumDashDot;
                case BorderStyle.MediumDashDotDot:
                    return DashStylesEx.MediumDashDotDot;
                case BorderStyle.MediumDashed:
                    return DashStyles.Dash;
                case BorderStyle.SlantDashDot:
                    return DashStyles.DashDot;
                case BorderStyle.Double:
                    return DashStyles.Solid;
                case BorderStyle.Thick:
                    return DashStyles.Solid;
                case BorderStyle.Thin:
                    return DashStyles.Solid;
                case BorderStyle.Medium:
                    return DashStyles.Solid;
                    default:
                    throw new NotSupportedException();
            }
        }


        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return StyleToDash((BorderStyle) value).Dashes;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}

  
